package com.ali.resource.CompoentPage;

import com.ali.resource.ShareTools.TeaopenapiClient;
import com.aliyun.cas20200407.Client;
import com.aliyun.cas20200407.models.ListCertRequest;
import com.aliyun.cas20200407.models.ListCertResponse;
import com.aliyun.cas20200407.models.ListUserCertificateOrderRequest;
import com.aliyun.cas20200407.models.ListUserCertificateOrderResponse;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SslComponent {

    @Autowired
    private TeaopenapiClient teaopenapiClient;


    public com.aliyun.cas20200407.Client getSslClient() throws Exception {
        Config client1 = teaopenapiClient.getClient();
        client1.endpoint = "cas.aliyuncs.com";

        Client client = new Client(client1);
        return client;
    }

    public com.aliyun.cas20200407.models.ListUserCertificateOrderRequest getListRequest(){
        ListUserCertificateOrderRequest listUserCertificateOrderRequest = new ListUserCertificateOrderRequest();
        listUserCertificateOrderRequest.setOrderType("CERT");
        return listUserCertificateOrderRequest;
    }

    public com.aliyun.cas20200407.models.ListUserCertificateOrderResponse getListResponse(com.aliyun.cas20200407.models.ListUserCertificateOrderRequest request) throws Exception {
        Client sslClient = this.getSslClient();
        ListUserCertificateOrderResponse listUserCertificateOrderResponse = sslClient.listUserCertificateOrderWithOptions(request, teaopenapiClient.getRunTime());
        return listUserCertificateOrderResponse;
    }

}
